#pragma once

#include <iostream>
#include <pthread.h>

class LockGuard
{
public:
	LockGuard(pthread_mutex_t *mutex) : m_mutex(mutex)
	{
		pthread_mutex_lock(m_mutex);//构造锁
	}

    ~LockGuard()
	{
		pthread_mutex_unlock(m_mutex);//析构解锁
	}

private:
	pthread_mutex_t *m_mutex;
};